package com.spring.mvc2.service;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.annotation.HandlesTypes;
import java.util.*;

/**
 * @Description TODO
 * @author ll
 */
@HandlesTypes(MyInterface.class)
public class MyServletContainerInitializer implements ServletContainerInitializer {

	@Override
	public void onStartup(Set<Class<?>> set,ServletContext context) {
		System.out.println(654321);
		List<MyInterface> list = new ArrayList<>();
		for (Class<?> aClass : set) {
			try {
				list.add((MyInterface) aClass.newInstance());
			} catch (InstantiationException | IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		for (MyInterface myInterface : list) {
			myInterface.start(context);
		}
	}

}
